package com.fbs.wowo.manage.web;

import com.fbs.wowo.base.BaseController;
import com.fbs.wowo.base.Response;
import com.fbs.wowo.manage.entity.User;
import com.fbs.wowo.manage.service.UserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理
 */
@RestController
@RequestMapping("/user")
public class UserController extends BaseController {
    /**
     * 模糊查询用户信息
     * 按id，姓名，电话 查找用户
     */
    @RequiresPermissions("role:query")
    @GetMapping("/search")
    public Response find(@RequestParam String query) {
        return success(userService.findByQueryString(query));
    }

    /**
     * 查找用户id
     */
    @GetMapping("/info")
    public Response findById(@RequestParam String userId) {
        return success(userService.findByUserId(userId));
    }


    /**
     * pc的用户详情
     * @param userId
     * @return
     */
    @GetMapping("/auth")
    public Response findUserInfoByPC(@RequestParam String userId) {
        return success(userService.findUserInfoByPC(userId));
    }

    /**
     * 修改头像
     * 补全注册信息
     * @param user
     * @return
     */
    @PostMapping("/modify")
    public Response modify(@ModelAttribute User user) {
        return success(userService.modify(user));
    }

    /**
     * 模糊查询用户信息
     * 按id，姓名，电话 查找用户
     */
    @GetMapping("/query")
    public Response findByQueryString(@RequestParam String query) {
        return success(userService.findByQueryString(query));
    }

    // 删除用户




    @Autowired
    private UserService userService;
}
